package com.nut.spp.api.admin;

import com.nut.spp.common.Result;
import com.nut.spp.entity.GoodsCompose;
import com.nut.spp.service.GoodsComposeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

@Slf4j
@RestController
@RequestMapping("/admin/goodsCompose")
public class GoodsComposeController {

    @Autowired
    private GoodsComposeService goodsComposeService;

    @GetMapping(value = "/goodsId/{goodsId}")
    public Result<List<GoodsCompose>> list(@PathVariable Integer goodsId) {
        return goodsComposeService.selectByGoodsId(goodsId);
    }

    @PostMapping
    public Result add(@RequestBody GoodsCompose goodsSpec) {
        return goodsComposeService.add(goodsSpec);
    }

    @PutMapping
    public Result update(@RequestBody GoodsCompose goodsSpec) {
        return goodsComposeService.updateById(goodsSpec);
    }

    @DeleteMapping
    public Result delete(@RequestBody Set<Integer> ids) {
        return goodsComposeService.deleteByIds(ids);
    }

}